package org.sport.model.entityModel;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by Allen on 2017/9/29.
 */
@Entity
@Table(name = "historyinfotable", schema = "sportinfo", catalog = "")
public class HistoryinfotableEntity {
    private Timestamp time;
    private String info;
    private int id;
    private String status;
    private UsertableEntity usertableByUserId;
    private UsertableEntity usertableByToWhoId;
    private GrouptableEntity grouptableByGroupId;

    @Basic
    @Column(name = "time", nullable = true)
    public Timestamp getTime() {
        return time;
    }

    public void setTime(Timestamp time) {
        this.time = time;
    }

    @Basic
    @Column(name = "info", nullable = true, length = 45)
    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    @Id
    @Column(name = "_id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "status", nullable = true, length = 45)
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        HistoryinfotableEntity that = (HistoryinfotableEntity) o;

        if (id != that.id) return false;
        if (time != null ? !time.equals(that.time) : that.time != null) return false;
        if (info != null ? !info.equals(that.info) : that.info != null) return false;
        if (status != null ? !status.equals(that.status) : that.status != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = time != null ? time.hashCode() : 0;
        result = 31 * result + (info != null ? info.hashCode() : 0);
        result = 31 * result + id;
        result = 31 * result + (status != null ? status.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "userId", referencedColumnName = "_id")
    public UsertableEntity getUsertableByUserId() {
        return usertableByUserId;
    }

    public void setUsertableByUserId(UsertableEntity usertableByUserId) {
        this.usertableByUserId = usertableByUserId;
    }

    @ManyToOne
    @JoinColumn(name = "toWhoId", referencedColumnName = "_id")
    public UsertableEntity getUsertableByToWhoId() {
        return usertableByToWhoId;
    }

    public void setUsertableByToWhoId(UsertableEntity usertableByToWhoId) {
        this.usertableByToWhoId = usertableByToWhoId;
    }

    @ManyToOne
    @JoinColumn(name = "groupId", referencedColumnName = "_id")
    public GrouptableEntity getGrouptableByGroupId() {
        return grouptableByGroupId;
    }

    public void setGrouptableByGroupId(GrouptableEntity grouptableByGroupId) {
        this.grouptableByGroupId = grouptableByGroupId;
    }
}
